package com.hmall.item.web;

import com.hmall.item.pojo.Item;
import com.hmall.item.pojo.PageDTO;
import com.hmall.item.pojo.Result;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @Auth: wpc
 * @Desc:
 * @Date: 2023/4/19 16:07
 */
@RestController
@RequestMapping("item")
public class ItemController {

    @Autowired
    private IItemService itemService;

    /**
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/list")
    public PageDTO listAll(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
        return itemService.listAll(page, size);
    }

    @GetMapping("/{id}")
    public Item getById(@PathVariable("id") long id) {
        return itemService.getById(id);
    }

    @PostMapping
    public void add(@RequestBody Item item) {
        
        itemService.save(item);
    }

    @PutMapping
    public void putAway() {

    }

    public void soldOut() {

    }


}
